package tongcheng.com.tongcheng.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import tongcheng.com.tongcheng.R;
import tongcheng.com.tongcheng.base.BaseViewHolder;
import tongcheng.com.tongcheng.bean.XinYuJiFenBean;

/**
 * Created by P on 2017/7/28.
 */

public class XinYuJiFenAdapter extends RecyclerView.Adapter<XinYuJiFenAdapter.jiFenViewHolder> {

    public Context mContext;
    public List<XinYuJiFenBean.DataBean> data;

    public XinYuJiFenAdapter(Context context,List<XinYuJiFenBean.DataBean> data) {
        this.mContext = context;
        this.data = data;
    }


    @Override
    public jiFenViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {


        View view = View.inflate(mContext, R.layout.item_xiyujifen, null);
        jiFenViewHolder jiFenViewHolder = new jiFenViewHolder(view);

        return jiFenViewHolder;
    }

    @Override
    public void onBindViewHolder(jiFenViewHolder holder, int position) {
        XinYuJiFenBean.DataBean dataBean = data.get(position);
        int status = dataBean.status;
        if(status == 1){
            holder.item_jifen_jifen.setText("信用分 +"+dataBean.score);
        }else if(status == 0){
            holder.item_jifen_jifen.setText("信用分 -"+dataBean.score);
        }

        holder.item_jifen_title.setText(dataBean.title);
        holder.item_jifen_time.setText(dataBean.create_time_format);
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class jiFenViewHolder extends BaseViewHolder{

        public TextView item_jifen_jifen,item_jifen_time, item_jifen_title;

        public jiFenViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void init(View itemview) {
            item_jifen_jifen=  itemview.findViewById(R.id.item_jifen_jifen);
            item_jifen_time=  itemview.findViewById(R.id.item_jifen_time);
            item_jifen_title=itemview.findViewById(R.id.item_jifen_title);
        }
    }

}
